/*
* @Author: majingyu
* @Date:   2017-05-30 15:52:21
* @Last Modified by:   jingyu.ma
* @Last Modified time: 2017-08-07 22:36:30
*/

import initialState from '../state';
import { date2time } from 'common/date'


function noticeReducer(state = initialState.notice, action){
    switch(action.type){
        case 'GET_NOTICE_SUCCESS':
            let noticeLists = state.noticeList.list
            action.data.rows.map(item => {
                noticeLists.push(item);
                item.ctime = date2time(item.ctime);
            })
            return Object.assign({},state,{
                noticeList:{
                    list:noticeLists,
                    pageNo: action.data.currentPageNumber,
                    total: action.total
                }
            });
        default :
            return state;
    }
}

export default noticeReducer;